
        (function () {

          const Dom = {
              card_tabbar: $('#card-tabbar'),
              card_tabbar_item: $('#card-tabbar .tabbar-item'),
              cards: $('.cards'),
              mobile: $('#mobile'),
              password: $('#password'),
              verifyCode: $('#verifyCode'),
              verifyCodePic: $('#verifyCodePic'),
              submitButton: $('#submitButton')
          }

          const Win = $(window)
          const Doc = $(document)

          let mobile = $utils.getLocalStorage('mobile') || ''
          let password = $utils.getLocalStorage('password') || ''
          let verifyCode = ''
          let checkVerifyCode = ''
          let recordPassword = true



          EventHandler()

          function EventHandler() {


              Dom.mobile.val(mobile)
              Dom.password.val(password)

              if (mobile && password) {
                  $('#recordPassword').addClass('active')
              }

              $('#recordPassword').click(function () {
                  let $el = $(this).toggleClass('active')
                  recordPassword = $el.is('.active')

                  if (!recordPassword) {
                      $utils.setLocalStorage('mobile', '')
                      $utils.setLocalStorage('password', '')
                  }
              })

              // 登录
              Dom.submitButton.click(async function () {

                  if (!mobile) {
                      $utils.showMsg('请输入手机号')
                      return
                  }
                  if (!password) {
                      $utils.showMsg('请输入密码')
                      return
                  }
                  if (!verifyCode) {
                      $utils.showMsg('请输入验证码')
                      return
                  }
                  if (verifyCode !== checkVerifyCode) {
                      $utils.showMsg('验证码不正确')
                      return
                  }

                  let params = { mobile, password }

                  $http.get('/member/api.passport/login', params).then(res => {

                    if(res.data.code == 0) {
                      $utils.showMsg(res.data.msg)
                    }
                    
                    $utils.showMsg(res.data.msg, function () {
                      if (res.code !== 0) {
                          $utils.setLocalStorage('mobile', mobile)
                          $utils.setLocalStorage('password', password)
                          location.href = '/'
                      }
                    })
                  })

                  
              })

              Dom.mobile.on('input', function () {
                  mobile = this.value
              })

              Dom.password.on('input', function () {
                  password = this.value
              })

              Dom.verifyCode.on('input', function () {
                  verifyCode = this.value
              })

              let cavnas = document.getElementById('canvas')
              checkVerifyCode = $utils.drawPic(Dom.verifyCodePic, cavnas)

              Dom.verifyCodePic.click(function () {
                  checkVerifyCode = $utils.drawPic(Dom.verifyCodePic, cavnas)
              })

              Dom.mobile.on('input', function () {
                  mobile = this.value
              })

              Dom.password.on('input', function () {
                  password = this.value
              })

              Dom.verifyCode.on('input', function () {
                  verifyCode = this.value
              })


          }


      })()